﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text.RegularExpressions;

namespace HitchHikersGuideToTheGalaxy.Helpers
{
    public class EmailValidator
    {
        static IDictionary<string, Regex> emailRegex = new Dictionary<string, Regex>() { 
            {"EMAIL", new Regex("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?")}
        };

        public static bool IsValidEmail(string email)
        {
            if (email != null)
            {
                return emailRegex["EMAIL"].IsMatch(email);
            }
            else
                return false;
        }

         public static IEnumerable<string> Countries
        {
            get
            {
                return emailRegex.Keys;
            }
        }

    }
}
